#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "rngs.h"
#include <time.h>

int main()
{
	srand(time(NULL));
	
	int seed = rand() % 5000 + 2;
    int numPlayer = 2;
    int bonus = 0;
    int i;
    int thisDeckCount;
    int thisHandCount;
    
	struct gameState state;
	int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse, sea_hag, tribute, smithy};

	for (i = 0; i < 1000; i++) {
		memset(&state, 23, sizeof(struct gameState)); // reset game state
		initializeGame(numPlayer, k, seed, &state);

		state.whoseTurn = 0;
		state.hand[0][0] = smithy; // ensure smithy is in player's hand

		state.handCount[0] = rand() % 10;
		state.deckCount[0] = rand() % 50 + 30;
		thisDeckCount = state.deckCount[0];
		thisHandCount = state.handCount[0];

		printf("Starting Deck Count: %d\n", state.deckCount[0]);	
		printf("Starting Hand Count: %d\n", state.handCount[0]);

		cardEffect(smithy, 0, 0, 0, &state, 0, &bonus);

		printf("Final Deck Count: %d\n", state.deckCount[0]);
		assert(thisDeckCount - state.deckCount[0] == 3);
		printf("Final Hand Count: %d\n", state.handCount[0]);
		assert(state.handCount[0] == thisHandCount + 2);
	}

	printf("All tests passed!\n");

	return 0;
}